# Generated automatically from Makefile.in by configure.
# Makefile for regex testing.
# 
# Copyright (C) 1992 Free Software Foundation, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.

CPPFLAGS =
CFLAGS = -g
LDFLAGS =

srcdir = .
VPATH = .:../.

CC = gcc
DEFS =  -DHAVE_STRING_H=1 -DHAVE_ALLOCA_H=1
LIBS =  $(LOADLIBES)

ETAGS = etags
SHELL = /bin/sh

debug = -DDEBUG
ALL_CPPFLAGS = -I. -I$(srcdir) -I../$(srcdir) $(DEFS) $(CPPFLAGS) $(debug)

.c.o:
	$(CC) $(ALL_CPPFLAGS) $(CFLAGS) -c $<


# Define this as `../regex.o' to get the optimized version.
regex_o = dregex.o
test_h = test.h
test_o = test.o bsd-interf.o other.o tregress.o psx-basic.o psx-extend.o \
         psx-generic.o psx-group.o psx-interf.o psx-interv.o
common_o = printchar.o upcase.o xmalloc.o $(malloc)

# We have a lot of mallocs we can try when we run afoul of strange bugs.
malloc = 
#malloc = # the libc malloc
#malloc = g++malloc.o
#malloc = debugmalloc.o
#malloc = emacsmalloc.o
emacsmallocflags = -Drcheck -Dbotch=abort -DUSG

# default is to do nothing.
default:

all: regex syntax

regex: $(regex_o) $(common_o) $(test_o) main.o
	$(CC) -o $@ $(LDFLAGS) $^ $(LIBS)

# As long as we're doing tests, we enable debugging.
dregex.o: ../regex.c ../regex.h
	rm -f $@
	$(CC) $(ALL_CPPFLAGS) $(CFLAGS) -c ../$(srcdir)/regex.c
	mv regex.o $@

# iregex is the interactive regex.
iregex: $(common_o) $(regex_o) iregex.o
	$(CC) -o $@ $(LDFLAGS) $^ $(LIBS)

# fileregex searches for an r.e. in every line of a given file.
fileregex_o = fileregex.o printchar.o $(regex_o)
fileregex: $(fileregex_o)
	$(CC) -o $@ $(LDFLAGS) $(fileregex_o) $(LIBS)

# cppregex is regex with a preprocessed regex.c.  Useful when the
# problem is inside some macro.
cppregex: regexcpp.o $(common_o) $(test_o) main.o
	$(CC) -o $@ $(LDFLAGS) $^ $(LIBS)

regexcpp.o: regexcpp.c 

regexcpp.c: regex.c regexcpp.sed
	rm -f regexcpp.c
	$(CC) -E $(ALL_CPPFLAGS) ../$(srcdir)/regex.c \
          | egrep -v '^#|^ *$$' \
          | sed -f regexcpp.sed \
          > regexcpp.c
	chmod a-w regexcpp.c

# Have to give this malloc special flags.
emacsmalloc.o: emacsmalloc.c
	$(CC) -c $(CFLAGS) $(ALL_CPPFLAGS) $(emacsmallocflags) \
	  ../$(srcdir)/test/emacsmalloc.c

syntax: syntax.o
	$(CC) $(CFLAGS) -o $@ syntax.o

syntax.c: syntax.skel bits
	sed '/\[\[\[replace.*\]\]\]/r bits' syntax.skel > $@

bits: regex.h
	sed -n 1,/RE_SYNTAX_EMACS/p ../$(srcdir)/regex.h \
          | grep "#define RE_.*1" \
          | sed 's/^#define \(RE_[A-Z_]*\) .*/  TEST_BIT (\1);/' > $@

check: regex
	./regex

TAGS: regex.c regex.h *.h *.c
	$(ETAGS) -t $^

depend:
	gcc -MM $(ALL_CPPFLAGS) *.c > /tmp/depend
.PHONY: depend

install:
.PHONY: install

clean mostlyclean:
	rm -f *.o regex cppregex iregex fileregex regexcpp.c syntax

distclean: clean
	rm -f bits syntax.c Makefile

extraclean: distclean
	rm -f *~* *\#* patch* *.orig *.rej *.bak core a.out

realclean: distclean
	rm -f TAGS

Makefile: Makefile.in ../config.status
	(cd ..; sh config.status)

# Prevent GNU make 3 from overflowing arg limit on system V.
.NOEXPORT:

# Assumes $(distdir) is the place to put our files.
distfiles = ChangeLog TAGS *.in *.c *.h regexcpp.sed syntax.skel
dist: Makefile TAGS
	mkdir $(distdir)
	ln $(distfiles) $(distdir)

# Automatically-generated dependencies below here.
alloca.o : alloca.c 
bsd-interf.o : bsd-interf.c 
debugmalloc.o : debugmalloc.c 
emacsmalloc.o : emacsmalloc.c getpagesize.h 
fileregex.o : fileregex.c .././regex.h 
g++malloc.o : g++malloc.c //usr/include/stdio.h getpagesize.h 
iregex.o : iregex.c .././regex.h 
main.o : main.c test.h .././regex.h 
malloc-test.o : malloc-test.c 
other.o : other.c test.h .././regex.h 
printchar.o : printchar.c 
psx-basic.o : psx-basic.c test.h .././regex.h 
psx-extend.o : psx-extend.c test.h .././regex.h 
psx-generic.o : psx-generic.c test.h .././regex.h 
psx-group.o : psx-group.c test.h .././regex.h 
psx-interf.o : psx-interf.c test.h .././regex.h 
psx-interv.o : psx-interv.c test.h .././regex.h 
syntax.o : syntax.c .././regex.h 
test.o : test.c test.h .././regex.h 
tregress.o : tregress.c test.h .././regex.h 
upcase.o : upcase.c 
xmalloc.o : xmalloc.c 
